package com.beiing.tianshuai.tianshuai.mine.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CommonBean;
import com.beiing.tianshuai.tianshuai.mine.entity.BindingBean;
import com.beiing.tianshuai.tianshuai.mine.model.BindingModel;
import com.beiing.tianshuai.tianshuai.mine.model.BindingModelImpl;
import com.beiing.tianshuai.tianshuai.mine.view.BindingViewImpl;

import okhttp3.ResponseBody;

/**
 * Created by Jinni on 2017/9/1 0001.
 */

public class BindingPresenter extends BasePresenter implements BindingPresenterImpl, BindingModel.OnRequestListener{

    private BindingViewImpl mView;
    private BindingModelImpl mModel;

    public BindingPresenter(BindingViewImpl view) {
        mView = view;
        mModel = new BindingModel(this);
    }

    @Override
    public void submitUserInfo(String platform, String unionId, String nickName, String avatarUrl, String sign, String tel, String code, String pass) {
        mView.showProgress();
        mModel.submitUserInfo(platform, unionId, nickName, avatarUrl, sign, tel, code, pass);
    }

    @Override
    public void getSignUpCode(String number) {
        mModel.getSignUpCode(number);
    }

    @Override
    public void isAlreadySignUp(String number) {
        mModel.isAlreadySignUp(number);
    }

    @Override
    public void onSuccess(BindingBean body) {
        mView.hideProgress();
        mView.bindingSuccess(body);
    }

    @Override
    public void onError(Throwable throwable) {
        mView.hideProgress();
        mView.bindingError(throwable);
    }

    @Override
    public void getSafeCodeSuccess(CommonBean bean) {
        mView.getSafeCodeResult(bean);
    }

    @Override
    public void isAlreadySignUp(CommonBean bean) {
        mView.isAlreadySignUp(bean);
    }
}